﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace AirlineBooking.Models.DTO
{
    public class DTOTitle
    {
        static DTOTitle(){
            using (AirLineDBModelEntities db = new AirLineDBModelEntities())
            {
                AirlineBooking.Title t = db.Titles.FirstOrDefault(i => i.Title1 == "Mr.");
                MR = t != null ? new DTOTitle(t) : null;
                t = db.Titles.FirstOrDefault(i => i.Title1 == "Miss.");
                MISS = t != null ? new DTOTitle(t) : null;
                t = db.Titles.FirstOrDefault(i => i.Title1 == "Ms.");
                MS = t != null ? new DTOTitle(t) : null;
                t = db.Titles.FirstOrDefault(i => i.Title1 == "Dr.");
                DR = t != null ? new DTOTitle(t) : null;
            }
        }

        private DTOTitle(int id, string value)
        {
            Id = id;
            Value = value;
        }

        private DTOTitle(AirlineBooking.Title title)
            : this(title.Id, title.Title1)
        {
        }
        public string Value { get; set; }
        public int Id { get; set; }
        public static readonly DTOTitle MR;
        public static readonly DTOTitle MISS;
        public static readonly DTOTitle MS;
        public static readonly DTOTitle DR;
    }
}